<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../static/easyui/jquery.min.js"></script>
</head>
<body>
	<script type="text/javascript">
	function setXls(obj){
		var f=$(obj).val();
		alert(f);
		console.log(obj);
	    if(f == null || f == undefined || f == ''){
	        return false;
	    }
	    if(!/\.(?:xls)$/.test(f)){
	        alert("类型必须是图片(.png|jpg|bmp|gif|PNG|JPG|BMP|GIF)");
	        $(obj).val('');
	        return false;
	    }
	    var data = new FormData();
	    console.log(data);
	    $.each($(obj)[0].files,function(i,file){
	        data.append('file', file);
	    });
	    console.log(data);
	    $.ajax({
	        type: "POST",
	        url: "uploadXls",//GLOBAL_INFO.WEBURL_PREFIX+"business/uploadImg.xhtml",
	        data: data,
	        cache: false,
	        contentType: false,    //不可缺
	        processData: false,    //不可缺
	        dataType:"json",
	        success: function(ret) {
	        	/*console.log(ret);
	            if(ret.code==0){
	                    $("#photoUrl").val(ret.result.url);//将地址存储好
	                    $("#photourlShow").attr("src",ret.result.url);//显示图片   
	                    alertOk(ret.message);
	            }else{
	                alertError(ret.message);
	                $("#url").val("");
	                $(obj).val('');
	            }*/
	        },
	        error: function(XMLHttpRequest, textStatus, errorThrown) {
	            alert("上传失败，请检查网络后重试");
	        }
	    });
	}
	</script>
	<div class="form-group">
		<label for="inputPassword3" class="col-sm-2 control-label">上传图片:</label>
	    <div class="col-sm-10">
	    <input type="hidden" name="img"  id="photoUrl"/>
	    <input type="file" name="logoFile" id="logoFile" onchange="setXls(this)">
	    <span><img id="photourlShow" src="" width="300" height="197"/></span>
	    </div>
	</div>
</body>
</html>